{% extends "cfp/event/base.html" %}

{% load event_tags %}
{% load i18n %}
{% load orga_edit_link %}
{% load rich_text %}
{% load rules %}

{% block content %}
    {% with cfp=request.event.cfp %}
        {% has_perm "base.list_featured_submission" request.user request.event as can_view_featured_submissions %}
        {% has_perm "base.update_event" request.user request.event as can_edit_cfp %}
        <div class="d-flex align-items-start">
            <h1>{{ cfp.headline|default:"" }}</h1>
            {% if can_edit_cfp %}
                {% orga_edit_link request.event.cfp.urls.text %}
            {% endif %}
        </div>
        {{ cfp.text|rich_text }}
        {% if request.event.cfp.settings.show_deadline and request.event.cfp.max_deadline %}
            <p>
                <strong>
                    {% if cfp.is_open %}
                        {% blocktranslate with deadline=cfp.max_deadline|date:"SHORT_DATETIME_FORMAT" timezone=request.timezone until_string=cfp.max_deadline|timeuntil trimmed %}
                            You can enter proposals until {{ deadline }} ({{ timezone }}), {{ until_string }} from now.
                        {% endblocktranslate %}
                    {% else %}
                        {% blocktranslate with deadline=cfp.max_deadline|date:"SHORT_DATETIME_FORMAT" timezone=request.timezone trimmed %}
                            This Call for Papers closed on {{ deadline }} ({{ timezone }}).
                        {% endblocktranslate %}
                    {% endif %}
                </strong>
            </p>
        {% endif %}
        <div class="url-links">
            {% if request.event.current_schedule and request.event|get_feature_flag:"show_schedule" %}
                <a class="btn btn-info btn-lg btn-block" href="{{ request.event.urls.schedule }}">
                    {{ phrases.agenda.view_schedule }}
                </a>
            {% elif can_view_featured_submissions and has_featured %}
                <a class="btn btn-info btn-lg btn-block" href="{{ request.event.urls.featured }}">
                    {{ phrases.agenda.view_schedule_preview }}
                </a>
            {% endif %}
            {% if has_submissions and request.user.is_authenticated %}
		        <a class="btn btn-info btn-lg btn-block" href="{{ request.event.urls.user_submissions }}">
		            {{ phrases.agenda.view_own_submissions }}
		        </a>
            {% endif %}

            {% if has_submissions and request.user.is_authenticated %}
		        <a class="btn btn-info btn-lg btn-block" href="{{ request.event.urls.user }}">
		            {% translate "View or edit speaker profile" %}
		        </a>
            {% endif %}

            <a class="btn btn-success btn-lg btn-block {% if not cfp.is_open and not access_code.is_valid %}disabled{% endif %}"
               href="{{ request.event.urls.submit }}{{ submit_qs }}">
                {% if cfp.is_open or access_code.is_valid %}
                    {% translate "Submit a proposal" %}
                {% else %}
                    {% translate "Proposals are closed" %}
                {% endif %}
            </a>
        </div>
    {% endwith %}
{% endblock content %}
